From: Samuel Thibault Date: Fri, 21 Mar 2014 01:56:56 +0000 (+0100) Subject: PV-GRUB: fix blk access at end of disk X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5360 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=51e18e41e39a682de5a2e60ad86048dc6344efec;p=xen.git PV-GRUB: fix blk access at end of disk GRUB usually always loads a whole disk track, even if that means going beyond the end of the disk. We thus have to gracefully return an error, instead of letting the blkfront go panic. Signed-off-by: Samuel Thibault Acked-by: Ian Campbell --- diff --git a/stubdom/grub/mini-os.c b/stubdom/grub/mini-os.c index 8cecf9013f..64ab962fee 100644 --- a/stubdom/grub/mini-os.c +++ b/stubdom/grub/mini-os.c @@ -126,6 +126,9 @@ biosdisk (int read, int drive, struct geometry *geometry, if (i >= blk_nb) return -1; + if (sector + nsec > geometry->total_sectors) + return -1; + aiocb.aio_dev = blk_dev[i]; aiocb.aio_buf = addr; aiocb.aio_nbytes = (size_t)nsec * blk_info[i].sector_size;